{extend name="admin/public:layout" /}
{block name="title"}圈子管理{/block}
{block name="head"}{/block}
{block name="body"}
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li><i class="fa fa-hand-o-right"></i> <a href="{:url('index')}"> 圈子管理</a></li>
                <li class="active">编辑圈子</li>
            </ol>
        </div>
        <div class="ibox-content">
            <form method="post" class="form-horizontal" id="form">
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">圈子名称</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" placeholder="请输入圈子名称"
                               name="circle_name" value="{$info.circle_name}" datatype="*" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">圈子分类</label>
                    <div class="col-sm-4">
                        <select class="form-control" name="circle_class_id">
                            <option>请选择圈子分类</option>
                            {volist name="circleClass" id="vo"}
                            <option value="{$vo.class_id}" {eq name="info.circle_class_id" value="$vo['class_id']"}selected{/eq}>{$vo.class_name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">是否推荐</label>
                    <div class="col-sm-4">
                        <label class="radio-inline i-checks">
                            <input type="radio" name="is_recommend" value="0" {eq name="info.is_recommend" value="0"}checked{/eq} /> 否
                        </label>
                        <label class="radio-inline i-checks">
                            <input type="radio" name="is_recommend" value="1" {eq name="info.is_recommend" value="1"}checked{/eq} /> 是
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">圈子描述</label>
                    <div class="col-sm-8">
                        <textarea name="circle_desc" class="form-control">{$info.circle_desc}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">圈子TAG</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" placeholder="请输入圈子TAG"
                               name="circle_tag" value="{$info.circle_tag}" datatype="*" />
                        <p class="help-block">每个tag按,隔开</p>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">圈子图片</label>
                    <div class="col-sm-4">
                        <p class="form-control-static">
                            {:widget('common/Form/singleImg',['circle_img',$info['circle_img'],-2])}
                        </p>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">圈子公告</label>
                    <div class="col-sm-8">
                        <textarea name="circle_notice" class="form-control">{$info.circle_notice}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">圈子状态</label>
                    <div class="col-sm-4">
                        <label class="radio-inline i-checks">
                            <input type="radio" name="circle_status" value="0" {eq name="info.is_recommend" value="0"}checked{/eq} /> 关闭
                        </label>
                        <label class="radio-inline i-checks">
                            <input type="radio" name="circle_status" value="1" {eq name="info.is_recommend" value="1"}checked{/eq} /> 开启
                        </label>
                    </div>
                    <label class="col-sm-1 control-label Validform_label">圈主</label>
                    <div class="col-sm-3">
                        {$member_name|default='未指定'}
                        <button type="button" class="btn btn-warning" onclick="setIdentity()">指定圈主</button>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">是否审核</label>
                    <div class="col-sm-4">
                        <label class="radio-inline i-checks">
                            <input type="radio" name="circle_joinaudit" value="0" {eq name="info.is_recommend" value="0"}checked{/eq} /> 否
                        </label>
                        <label class="radio-inline i-checks">
                            <input type="radio" name="circle_joinaudit" value="1" {eq name="info.is_recommend" value="1"}checked{/eq} /> 是
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">圈子管理员</label>
                    <div class="col-sm-8">
                        {eq name="adminInfo.admin_power" value="3"}
                        <input type="text" class="form-control" placeholder="请输入圈子管理员账号"
                               name="circle_mastername" value="{$adminInfo.admin_name}" datatype="*" readonly />
                        {else}
                        <input type="text" class="form-control" placeholder="请输入圈子管理员账号"
                               name="circle_mastername" value="" datatype="*" />
                        {/eq}
                        <p class="help-block">可以管理该圈子前端动态，审批会员申请圈子请求</p>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-10 col-sm-offset-2">
                        <button class="btn btn-primary" type="button" id="btnSub">保存内容</button>
                        <a href="{:url('index')}" class="btn btn-white">取消</a>
                        <span id="validError"></span>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script src="/public/plugins/template/template.js"></script>
<script type="text/html" id="info-tpl">
    <div class="input-group">
        <input type="text" placeholder="查找用户" id="name" class="input form-control">
        <span class="input-group-btn">
          <button type="button" class="btn btn btn-primary" onclick="searchMember()"> <i class="fa fa-search"></i> 搜索</button>
        </span>
    </div>
    <table class="table">
        <thead>
        <tr>
            <th>账号</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="member_list">
        </tbody>
    </table>
</script>
<script type="text/html" id="member_tpl">
    {{ each data as value}}
        <tr>
            <td>{{ value.member_name}}</td>
            <td>
                <button type="button" class="btn btn-warning" onclick="setIdentity2('{{ value.member_id}}')">设为圈主</button></td>
        </tr>
    {{ /each}}
</script>
<script type="text/javascript">
    $(function () {
        iCheck();
        ajaxSubForm('#btnSub');
    });
    function setIdentity() {
        var html=template('info-tpl',{});
        layer.open({
            title:'指定圈主',
            type: 1,
            skin: 'layui-layer-demo', //样式类名
            closeBtn: 0, //不显示关闭按钮
            anim: 2,
            shadeClose: true, //开启遮罩关闭
            content: html
        });
    }
    function searchMember() {
        var member_name=$('#name').val();
        $.post('{:url("setIdentity")}',{circle_id:'{$info.circle_id}',member_name:member_name},function (res) {
            var html=template('member_tpl',{data:res});
            $('#member_list').empty().html(html);
        })
    }
    function setIdentity2(member_id) {
        $.post('{:url("setIdentity")}',{circle_id:'{$info.circle_id}',member_id:member_id},function (res) {
            layer.msg(res.msg);
            if (res.code){
                window.location.reload();
            }
        })
    }
</script>
{/block}